<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <style>
    .sty {
      width: 200px;
      height: 40px;
      line-height: 40px;
    }
    .color {
      background-color: yellowgreen;
      font-size: 24px;
      white-space: nowrap;
      overflow: hidden;
    }
  </style>
  <script type='text/javascript' src='js/vue.js'></script>
</head>
<body>
  <div id='app'>
    <button @click="start">循环</button>
    <button @click="pause">暂停</button>
    <div :class="styArr">{{msg}}</div>
  </div>
  <script type='text/javascript'>
    var vm = new Vue({
      el: '#app',
      data: {
        msg: '我欲乘风归去，何必秋风悲画扇！',
        timer: null,
        flag: true,
        styArr: ['sty','color']
      },
      methods: {
        start() {
          if(!this.flag) {
            return 
          }
          this.flag = false;
          this.timer = setInterval(() => {
            let newStr = `${this.msg.substr(1)}${this.msg[0]}`;
            this.msg = newStr;
          },200)
        },
        pause() {
          clearInterval(this.timer);
          this.flag = true;
        }
      }
    });
  </script>
</body>
</html>